package com.cjc.springcloud.controller;


import com.cjc.springcloud.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import com.cjc.springcloud.entity.CommonResult;
import com.cjc.springcloud.entity.Payment;


/**
 * @ClassName Payment
 * @Description: TODO
 * @Author cjc
 * @Date 2020/6/17
 * @Version V1.0
 **/
@RestController
@RequestMapping("payment")
public class PaymentController {
    @Value("${server.port}")
    private String port;
    @Autowired
    private PaymentService paymentService;
    @PostMapping("add")
    public CommonResult add(@RequestBody Payment payment){
        int i = paymentService.create(payment);
        if(i<=0){
            return new CommonResult(500,"111111"+port);
        }else{
            return new CommonResult(200,"success"+port);
        }
    }
    @GetMapping("getById/{id}")
    public CommonResult getById(@PathVariable("id") Long id){
            return new CommonResult(500,"111111"+port,paymentService.getPaymentById(id));

    }
}
